Skip to content

feat: passthrough extra args for adk deploy cloud_run as Cloud Run args #2544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jackwotherspoon
Copy link
Contributor

@jackwotherspoon jackwotherspoon commented Aug 14, 2025

The command adk deploy cloud_run supports limited gcloud run deploy args 😢.

Which makes the command fine for simple deployments...

It should support all current and future Cloud Run deployment args for the command to be widely adopted.

This can easily be done by passing through all extra args passed to adk deploy cloud_run to gcloud...

This PR assumes any extra args/flags passed after AGENT_PATH are gcloud flags.

Example

# ADK flags
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
$AGENT_PATH \
# NEW gcloud run deploy flags
--min-instances=2 \
--no-allow-unauthenticated

This gives full Cloud Run feature support to ADK users 🤖 🚀

Test Plan

To test you can just build locally or pip install feature branch directly:

uv venv
uv pip install git+https://github.com/jackwotherspoon/adk-python.git

Deploy to Cloud Run using additional arguments following AGENT_PATH, such as --min-instance=2 or --description="Cloud Run test":

uv run adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
--with_ui \
$AGENT_PATH \
--labels=test-label=adk \
--min-instances=2

You can click on the Cloud Run service after deployment and check the service yaml, you should see the additional label etc.

image

Fixes #2351

@adk-bot
Copy link
Collaborator

adk-bot commented Aug 14, 2025

Response from ADK Triaging Agent

Hello @jackwotherspoon, thank you for creating this PR!

To help us review this PR, could you please address the following from our contribution guidelines:

  • Single Commit: Please squash the multiple commits into a single commit.
  • Testing Plan: Please include a testing plan section in your PR description to detail how you've tested these changes.

You can find more details in our contribution guidelines.

This information will help reviewers to review your PR more efficiently. Thanks!

@hangfei
Copy link
Collaborator

hangfei commented Aug 14, 2025

Please add testing plan(log or screenshot)

@hangfei hangfei self-requested a review August 14, 2025 21:57
@adk-bot
Copy link
Collaborator

adk-bot commented Aug 14, 2025

Response from ADK Triaging Agent

Hello @jackwotherspoon, thank you for updating the PR with a testing plan!

Before this can be reviewed, could you please address the following:

  • CI Checks: The pyink-check and test (3.9) checks are failing. Please fix these issues so all checks are passing.
  • Single Commit: As mentioned previously, please squash the multiple commits into a single one.

You can find more details in our contribution guidelines.

These changes are needed before the reviewers can proceed. Thank you!

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools labels Aug 15, 2025
@adk-bot adk-bot requested a review from seanzhou1023 August 15, 2025 12:58
called_kwargs = rec.calls[0][1]
extra_args = called_kwargs.get("extra_gcloud_args")
assert extra_args is not None
assert "--labels=test-label=test" in extra_args
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is adk-labels? could you assert that?

user_labels_value = arg[9:] # Remove '--labels=' prefix
user_labels.append(user_labels_value)
else:
extra_args_without_labels.append(arg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if extra arg conflicts with existing args? raise error(other than the labels)?

@Jacksunwei
Copy link
Collaborator

@jackwotherspoon I see there is a merge conflict, could you help resolve?

@deploy.command("cloud_run")
@deploy.command(
"cloud_run",
context_settings={
Copy link
Collaborator

@Jacksunwei Jacksunwei Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it harder to maintain long-term.

I'd recommend adding a --gcloud_extra_arg option (with --multiple=True) to host.

Usage pattern could be --gcloud_extra_arg="--args1=val1" --gcloud_extra_arg="--args2=val2"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it harder to maintain long-term.

@Jacksunwei can you explain why this makes it harder to maintain...?

Seems way easier to maintain than the current approach of adding supported flags one by one.

Copy link
Contributor Author

@jackwotherspoon jackwotherspoon Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage pattern could be --gcloud_extra_arg="--args1=val1" --gcloud_extra_arg="--args2=val2"

From a DevX perspective I find this much worse than my current approach (in my opinion), you are asking folks to learn something new and have to do extra work to convert...

Versus telling folks to "take any of your existing Cloud Run deployments and copy your flags and just append them to your command".

The second option feels a bit more magical and it "just works"

Copy link
Collaborator

@Jacksunwei Jacksunwei Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes things confusing. From user's perspective, when they do adk deploy cloud_run --arg1 val1 --arg2 val2.

There is no easy way to tell whether arg1 is for adk deploy cloud_run or for the underlying gcloud command.

User cannot have help text from adk deploy cloud_run --help, either.

It appears to be doing less things, but it will just confuse people and shut our door to provide any additional options in the future, because if gcloud also has an option of the same name, we may accidentally break users' existing setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jacksunwei I think you may be mis-understanding...

Anything after AGENT_PATH is considered a gcloud arg, everything before is ADK flag...

# ADK flags
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
$AGENT_PATH \
# NEW gcloud run deploy flags
--min-instances=2 \
--no-allow-unauthenticated

There is no easy way to tell whether arg1 is for adk deploy cloud_run or for the underlying gcloud command.

Yes there is, anything before AGENT_PATH is an ADK arg, if I try and add a gcloud flag before AGENT_PATH it will error:

Try 'adk deploy cloud_run --help' for help.

Error: No such option: --allow-unauthenticated

User cannot have help text from adk deploy cloud_run --help, either.

Yes they can, adk deploy cloud_run --help, works fine. Only time it would potentially not work is --help after the AGENT_PATH.

because if gcloud also has an option of the same name, we may accidentally break users' existing setup.

This is a fair point, but do we really see this being the case...? Is there a plan to add a bunch more flags to adk deploy cloud_run? The benefits here seem to be huge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot tools [Component] This issue is related to tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for --add-cloudsql-instances flag in adk deploy cloud_run command
4 participants